var express = require('express');
var router = express.Router();
var db=require("../sql.js");


router.get('/', function(req, res, next) {
  res.render('index');
});
router.post("/main",function(req,res,next){
  var val=req.body;
  var userName=val.userName;
  var userPwd=val.userPwd;
  db.query("selcet * from user where userName=? and userPwd=?",[userName,userPwd],function(err,data){
    if(err){
      throw err;
    }else if(data.length>0){
      res.end("1111111");
    }else{
      res.writeHead(200,{"Content-Type":"text/html;charset=utf8"});
      res.end("登录失败");
    }
  })

})

module.exports = router;
